package com.wanmao.test.shebei;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class SBNode<T extends SBNode> implements Comparable<SBNode>, Serializable {
    public int  id;
    public int  pId;
    public int level;
    public boolean isExpand;
    public List<T> childNodes;


    public SBNode(int id, int pId, int level, boolean isExpand) {
        this.id = id;
        this.pId = pId;
        this.level = level;
        this.isExpand = isExpand;
    }



    public boolean hasChild() {
        return childNodes !=null  && !childNodes.isEmpty();
    }

    public void addChild(T node) {
        if (childNodes ==null ) {
            childNodes = new ArrayList<>();
        }
        childNodes.add(node);
    }

    @Override
    public int compareTo(SBNode sbNode) {
        if (id==sbNode.id){
            return 0;
        }else {
            return 1;
        }
    }

}
